package com.example.zzm.yuejian03.Activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.example.zzm.yuejian03.Adapter.TrainAdapter;
import com.example.zzm.yuejian03.Bean.TrainBean;
import com.example.zzm.yuejian03.Listener.TrainListener;
import com.example.zzm.yuejian03.Model.TraincModel;
import com.example.zzm.yuejian03.R;

import java.util.List;

public class TraincActivity extends AppCompatActivity implements View.OnClickListener{

    private RecyclerView recyclerView;
    private TextView textView11;

    public void  onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_train);
        initViews();
        initEvent();
//        int club_id = getIntent().getIntExtra("train_id",1);
//        TrainModel classModel = new TrainModel();
//        classModel.getTrainList(listener);
        TraincModel model = new TraincModel();
        model.getTrainList(listener);
    }

    TrainListener listener = new TrainListener() {
        @Override
        public void onResponse(List<TrainBean> beanlist) {
            TrainAdapter TrainAdapter = new TrainAdapter(getApplicationContext(),beanlist);
            recyclerView.setAdapter(TrainAdapter);
        }

        @Override
        public void onFail(String msg) {

        }
    };

    private void initEvent() {
        textView11.setOnClickListener(this);
    }

    private void initViews() {
        textView11 = (TextView)findViewById(R.id.textView11);
        recyclerView = (RecyclerView)findViewById(R.id.recyclerview);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this.getApplicationContext());
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.textView11:
                finish();
                break;
        }
    }
}
